package com.jiyun.testlist.controller;

import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A;
import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.C;
import com.aliyun.tea.Tea;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jiyun.model.Dept;
import com.jiyun.model.Quiz;
import com.jiyun.model.Team;
import com.jiyun.model.User;
import com.jiyun.testlist.service.*;
import com.jiyun.vo.QuizVo;
import com.jiyun.vo.TeamVo;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("quiz")
public class QuizController  {

    @Autowired
    QuizService quizService;

    @Autowired
    CourseService courseService;

    @Autowired
    RaceService raceService;

    @Autowired
    TrainService trainService;

    @Autowired
    UserService userService;

    @Autowired
    TeamService teamService;

    @Autowired
    RedisTemplate redisTemplate;

    @Autowired
    DeptService deptService;


    @RequestMapping("findPage")
    public Page<QuizVo>findPage(@RequestParam Integer pageNum,@RequestParam Integer pageSize,@RequestBody QuizVo quizVo){
      return   quizService.findPage(pageNum,pageSize,quizVo);
    }

    @RequestMapping("findPage2")
    public Page<TeamVo>findPage2(@RequestParam Integer pageNum, @RequestParam Integer pageSize, @RequestBody TeamVo teamVo){
      return   teamService.findPage(pageNum,pageSize,teamVo);
    }

//    统计课程人数
    @RequestMapping("find1")
    public Integer find1(){
      return courseService.find1();
    }

//    统计竞赛人数
    @RequestMapping("find2")
    public Integer find2(){
      return raceService.find2();
    }

//    统计培训人数
    @RequestMapping("find3")
    public Integer find3(){
      return trainService.find3();
    }

//    统计测验人数
    @RequestMapping("find4")
    public Integer find4(){
      return quizService.find4();
    }

//    统计登录人名称
    @RequestMapping("find5")
    public String find5(){
        String id =(String) redisTemplate.opsForValue().get("gogogo");
        return userService.find5(Integer.parseInt(id));
    }

//    删除战队
    @RequestMapping("deleteOne")
    public void deleteOne(@RequestParam Integer id){
        teamService.removeById(id);
    }

//    新增战队
    @RequestMapping("addteam")
    public void addteam(@RequestBody Team team){
        teamService.save(team);
    }

//    修改战队
    @RequestMapping("updateteam")
    public void updateteam(@RequestBody Team team){
        teamService.updateById(team);
    }

//    查询用户表
    @RequestMapping("findUser")
    public List<User> findUser(){
      return userService.list();
    }

//    查询部门表
    @RequestMapping("findDept")
    public List<Dept>findDept(){
      return deptService.list();
    }

}
